package com.turman.blibrary.log;

import static com.turman.blibrary.log.BLogConfig.MAX_LEN;

import android.util.Log;

import androidx.annotation.NonNull;

/**
* 控制台打印器
* @author buobao
* @since 2024/2/27 10:04
*/
public class BConsolePrinter implements BLogPrinter{
    @Override
    public void print(@NonNull BLogConfig config, int level, String tag, @NonNull String content) {
        int len = content.length();
        int countOfSub = len / MAX_LEN;
        if (countOfSub > 0) {
            int index = 0;
            for (int i = 0; i < countOfSub; i++) {
                Log.println(level,tag,content.substring(index,index+MAX_LEN));
                index += MAX_LEN;
            }
            if (index != len) {
                Log.println(level,tag,content.substring(index,len));
            }
        } else {
            Log.println(level,tag,content);
        }
    }
}
